Integration between Google Assistant and Servicenow tool is instructing google assistant application to perform certain task in service-now tool for us through our voice command.
For example we can give command "open incident" to google assistant application and it will create an incident in servicenow tool. After creating incident in service-now tool, service-now tool will give the response to google assistant application.
We are going to follow the steps below:
1.Create Google Assistant Project i.e. Call Servicenow
2.Create one Invocation Name i.e. Mr. Now
3.Create Intent i.e. create incident
4.Create Training Phrases for Intent i.e. create incident and open incident
5.Create Entities for Intent i.e option and incident
6.Create scripted Rest scripted webservice in Servicenow i.e. googleassistant
7.Enable Webhook in Fulfilment and user the scripted servicenow webservice for communication.
Google Assistant Integration with Service-now - Youtube Video Link
Lets go through steps:
1. First Go to --> Google Assistant Console
2.Search "Google Assistant Console" in google
3.Click on "Google Assistant | Google Developers"
4.Click on "Go to Actions Console"
5.Click on "New Project"
6.Agree the Terms and Services
7.Give the Project Name and select the Language and Country
8.Click on "Assistant SDK"
9. Click on "OK"
10. Now you can see all the options on the Action Console like
a.Overview
b.Develop
c.Test
d.Deploy
e.Analytics
11.Click on Develop Tab and give the Display Name and select Google Assistant Voice and SAVE.
12. Go to "Action" and Click on Get Started
13. Click on "Build", It will go to Dialog Flow
14. Please select Country and accept Terms and Services.
15.You will get Dialog Flow Window, please give the name as "Call-Servicenow" and Click on Create
16. Now Create Intent
17.After Creating Intent as "create incident", click on Intent Menu, you will get the new intent in the list (Dont forgot to Save)
18. Scroll Down and Select the "Training Phrases", Add Training Phrases (Dont forgot to Save)
19. Add the Training Phrases (Dont forgot to Save)
20. Check the Training Phrases
21.Create Entities like what I have created like option and incident (Dont forgot to Save)
22. Go to Intent list and selct the intent "create incident" and go to created Training Phrases
23. Select "open" from Training Phrases and select the option as entity
24. Select "incident" from Training Phrases and select the incident as entity
25. Go to "Action and Parameters" and select as "Required"
26. Now go to Fullfillment of the created intent and enable it.
Enable Webhook call for this intent.
26.1 Go to your servicenow instance and create one scripted webservice as per below screen shots and scripted
Please refer the below script:
(function process( /*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
var responseMsg = response.getStreamWriter(),
responseType = {};
var x = request.body.data;
gs.info("request data Pavan" + x);
var context = '';
var message = '';
data = {};
// if (x.queryResult.intent.displayName == 'open incident') create incident
if (x.queryResult.intent.displayName == 'create incident')
{
// var numbers = x.queryResult.parameters.number + "";
var incidentNumber = "";
var gr = new GlideRecord("incident");
gr.initialize();
gr.short_description = "This is just short description";
gr.description = "Testing Google Assistance ";
gr.assigned_to = "5aed35dddb9f00108b8bd1b1ca9619b0";
var tt = gr.insert();
gr.addQuery("sys_id", tt);
gr.query();
if (gr.next()) {
incidentNumber = gr.number;
}
message = "We have raised an incident " + incidentNumber + " and assigned to " + gr.assigned_to.name;
context = 'success';
} else if (x.queryResult.intent.displayName == 'get incident') {
var tableName = x.queryResult.parameters.ticket + "";
var ticketNumber = x.queryResult.parameters.ticket_number + "";
var t = new GlideRecord("" + tableName);
t.addQuery("number", 'CONTAINS', ticketNumber);
t.query();
if (t.next()) {
message = "We have " + tableName + " with number " + ticketNumber + " and this " + tableName + "is assigned to " + t.assigned_to.name + ". This " + tableName + " having short description as " + t.short_description;
context = 'success';
} else {
message = "Sorry , we dont have " + tableName + " with number " + ticketNumber;
context = 'success';
}
}
responseType['Content-Type'] = 'application/json';
response.setStatus(200);
response.setHeaders(responseType);
var response_body = {
"fulfillmentText": message,
"payload": {
"google": {
"expectUserResponse": true,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": message
}
}
]
}
}
}
};
responseMsg.writeString(global.JSON.stringify(response_body));
})(request, response);
27. Go to Fullfillment section from left side.
Use basic auth for this intent and save it.
Provide the details as per below screen shot.
Please enable the small talk as well.
28. Now you can test using small Talk..if you are getting the response as you have configure in servicenow then you app is on correct track.
29. Now Go to "Inegration" menu from left nevigation and click on select the intent and click on "Manage Assistant App"
30. It will redirect to Action Console Again and now go to Test.